<?php
//  ------------------------------------------------------------------------ //
//                      USERPAGE - MODULE FOR XOOPS 2                        //
//                  Copyright (c) 2005-2006 Instant Zero                     //
//                     <http://xoops.instant-zero.com/>                      //
// ------------------------------------------------------------------------- //
//  This program is free software; you can redistribute it and/or modify     //
//  it under the terms of the GNU General Public License as published by     //
//  the Free Software Foundation; either version 2 of the License, or        //
//  (at your option) any later version.                                      //
//                                                                           //
//  You may not change or alter any portion of this comment or credits       //
//  of supporting developers from this source code or any supporting         //
//  source code which is considered copyrighted (c) material of the          //
//  original comment or credit authors.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
//  ------------------------------------------------------------------------ //

include_once "../../mainfile.php";
$xoopsOption['template_main'] = 'userpage_list.html';
include_once XOOPS_ROOT_PATH.'/header.php';
include_once XOOPS_ROOT_PATH.'/modules/userpage/include/functions.php';

$userpage_handler =& xoops_getmodulehandler('userpage', 'userpage');
$allowhtml = userpage_getmoduleoption('allowhtml');
$myts =& MyTextSanitizer::getInstance();



include_once XOOPS_ROOT_PATH.'/class/pagenav.php';
$limit = userpage_getmoduleoption('linesperpage');
$xoopsTpl->assign('allowrss', userpage_getmoduleoption('allowrss'));
//$xoopsTpl->assign('op', $op);
$start = isset($_GET['start']) ? intval($_GET['start']) : 0;
$critere = new Criteria('1', '1','=');
$critere->setLimit($limit);
$critere->setStart($start);
// tip, replace "up_created" with "up_uid" if you want to sort by user and not by date
$critere->setSort('up_created');
$critere->setOrder('DESC');
$pagescount = $userpage_handler->getCount();
$pagenav = new XoopsPageNav($pagescount, $limit , $start, 'start', 'op=list');
$xoopsTpl->assign('pagenav', $pagenav->renderNav());
$pages = array();
$pages = $userpage_handler->getObjects($critere);
foreach($pages as $page) {
	$page->setVar('dohtml',$allowhtml);
	$xoopsTpl->append('pages',array(
		'up_pageid' => $page->getVar('up_pageid'),
		'up_uid' => $page->getVar('up_uid'),
		'user_name' => $page->uname(),
		'up_title' => $page->getVar('up_title'),
		'up_text' => $page->getVar('up_text'),
		'up_created' => formatTimestamp($page->getVar('up_created'),userpage_getmoduleoption('dateformat')),
		'up_hits' => $page->getVar('up_hits')
	));
}
// Page's title
$xoopsTpl->assign('xoops_pagetitle', strip_tags(_USERPAGE_BOOK).' - '.$myts->htmlSpecialChars($xoopsModule->name()));
include_once(XOOPS_ROOT_PATH."/footer.php");
?>
